package com.kainitram.library.sm;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

/**
 * Base class for sliding content
 * 
 * @author Mino
 * 
 */
public abstract class BaseSlidingContentFragment extends Fragment implements
		SlidingContentFragment {

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {

		return inflater.inflate(getViewID(), null);
	}

	@Override
	public void onAttach(Activity activity) {
		super.onAttach(activity);

		BaseSlidingFragmentActivity act = (BaseSlidingFragmentActivity) activity;
		act.setTitle(String.format("%s - %s", act.getApplicationTitle(),
				this.getFragmentTitle()));
	}

	// ------------------------------------
	// --------- abstract methods ---------
	// ------------------------------------

	/**
	 * Get view id, for displaying fragment.
	 * 
	 * @return View id, represent fragment view.
	 */
	public abstract int getViewID();

	/**
	 * Get fragment title.
	 * 
	 * @return Fragment title for displaying in action bar.
	 */
	public abstract String getFragmentTitle();
}
